Here is a simple example of tiles use with spring's TilesConfigurer. There is really no need for spring but tiles definitions must somehow be initialized. If you do not use Spring you could use the following context listener that is exatcly how Spring configures tiles definitions: package com.opensymphony.webwork.views.tiles; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; import org.apache.struts.tiles.DefinitionsFactoryConfig; import org.apache.struts.tiles.DefinitionsFactoryException; import org.apache.struts.tiles.TilesUtil; import org.apache.struts.tiles.xmlDefinition.I18nFactorySet; /* * Modified from spring's source * * here's how a smaple web xml should look like: * <web-app> * <context-param> * <param-name>tilesDefinitions</param-name> * <param-value>/WEB-INF/tiles.xml</param-value> * </context-param> * * <listener> * <listener-class>com.opensymphony.webwork.views.tiles.TilesConfigurer</listener-class> * </listener> * </web-app> * * To use the definitions specified you would use a dispatcher result (since * tiles jsp is just another jsp) to render tiles view. */ public class TilesConfigurer implements ServletContextListener { private boolean initialized = false; public void contextInitialized (ServletContextEvent evt) { if (!initialized) { DefinitionsFactoryConfig factoryConfig = new DefinitionsFactoryConfig(); factoryConfig.setFactoryClassname(I18nFactorySet.class.getName()); factoryConfig.setParserValidate(true); factoryConfig.setDefinitionConfigFiles(evt.getServletContext().getInitParameter("tilesDefinitions")); try { TilesUtil.createDefinitionsFactory(evt.getServletContext(), factoryConfig); } catch (DefinitionsFactoryException e) { e.printStackTrace(); } initialized = true; } } public void contextDestroyed (ServletContextEvent evt) { } } |